<div id="page">
	<h3>Adverts</h3>
	<p class="bold">Novo banner</p>
	<form action="<?= $html->url('/pbanner/pbanner_adverts/group_banners/' . $this->params['pass'][0] . '/' . $this->params['pass'][0]); ?>" method="post" enctype="multipart/form-data">
		<p>
			<label for="name">Name:</label><br />
			<?= $form->text('PbannerBanner.name', array('class' => 'big')); ?>
		</p>
		<p>
			<label for="link">Link:</label><br />
			<?= $form->text('PbannerBanner.link', array('class' => 'big')); ?>
		</p>
		<p>
			<label for="file">File:</label><br />
			<?= $form->file('PbannerBanner.file'); ?>
		</p>
		<div class="clear"></div>
		<p>
			<?= $form->submit('Save', array('class' => 'button')); ?>
		</p>
	</form>

	<table>
		<caption class="left">Banners do anuncio</caption>
		<thead>
			<tr>
				<th>Name</th>
				<th>Data created</th>
				<th>Order</th>
				<th>Option</th>
			</tr>
		</thead>
		<tbody>
			<?php
				$lenght = count($banners);
				foreach($banners as $key => $banner){
					echo '<tr id="' . $key . '">';
						echo '<td>' . $banner['PbannerBanner']['name'] . '</td>';
						echo '<td>' . substr(str_replace('-', '/',$banner['PbannerBanner']['created']), 0, 10) . '</td>';
						if($key == 0){
							echo '<td>' . $html->link($html->image('/pbanner/img/ordenar_baixo.gif'), array('plugin' => 'pbanner', 'controller' => 'pbanner_adverts', 'action' => 'change_order', 'id' => $banner['PbannerBanner']['id'], $banner['PbannerBanner']['order'], 'down'), array(), false, false) . ' ' . $html->image('/pbanner/img/ordenar_cima_inativo.gif') . '</td>';
						}elseif($key == ($lenght - 1)){
							echo '<td>' . $html->image('/pbanner/img/ordenar_baixo_inativo.gif') . ' ' . $html->link($html->image('/pbanner/img/ordenar_cima.gif'), array('plugin' => 'pbanner', 'controller' => 'pbanner_adverts', 'action' => 'change_order', 'id' => $banner['PbannerBanner']['id'], $banner['PbannerBanner']['order'],'up'), array(), false, false) . '</td>';
						}else{
							echo '<td>' . $html->link($html->image('/pbanner/img/ordenar_baixo.gif'), array('plugin' => 'pbanner', 'controller' => 'pbanner_adverts', 'action' => 'change_order', 'id' => $banner['PbannerBanner']['id'], $banner['PbannerBanner']['order'],'down'), array(), false, false) . ' ' . $html->link($html->image('/pbanner/img/ordenar_cima.gif'), array('plugin' => 'pbanner', 'controller' => 'pbanner_adverts', 'action' => 'change_order', 'id' => $banner['PbannerBanner']['id'], $banner['PbannerBanner']['order'],'up'), array(), false, false) . '</td>';
						}
						echo '<td>' . $html->link($html->image('/pbanner/img/excluir.gif'), array('plugin' => 'pbanner', 'controller' => 'pbanner_adverts', 'action' => 'delete_banner', 'id' => $banner['PbannerBanner']['id'], $lenght, $banner['PbannerBanner']['order']), array(), 'Tem certeza que deseja excluir?', false) . '</td>';
					echo '</tr>';
				}
			?>
		</tbody>
	</table>
</div>
<div id="sidebar">
	<h4>About</h4>
	<p>Pequeno relatório do funcionamento do PBanner.</p>
	<?= $this->renderElement('menu', $menu); ?>
	<?= $this->renderElement('links'); ?>
</div>
<?= $this->renderElement('footer'); ?>
<script type="text/javascript">
	$().ready(function(){
		$('table tbody tr:odd').addClass('impar');
	});
</script>